﻿package src.view.ui 
{
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import src.event.menuEvent;
	
	/**
	 * 产品名称标题
	 * @author	MeatHill
	 * @version	0.1(2009-07-30)
	 */
	public class proTitleView extends Sprite
	{
		public static const WIDTH:uint = 316;
		
		private var _label_txt:TextField;
		private var _extend_btn:SimpleButton;
		private var _is_menu_extended_bl:Boolean = false;
		
		public function proTitleView(pro_name:String) 
		{
			_label_txt = TextField(getChildAt(1));
			_label_txt.mouseEnabled = false;
			_extend_btn = SimpleButton(getChildAt(2));
			_extend_btn.addEventListener(MouseEvent.CLICK, click_handler);
			
			name = pro_name;
		}
		
		/**************
		 * properties
		 * ***********/
		public function set extended(bl:Boolean):void {
			_is_menu_extended_bl = bl;
			if (bl) {
				_extend_btn.scaleY = -_extend_btn.scaleY;
				_extend_btn.y -= _extend_btn.height;
			} else {
				_extend_btn.scaleY = 1;
				_extend_btn.y += _extend_btn.height;
			}
		}
		
		/**************
		 * functions
		 * ***********/
		private function click_handler(evt:MouseEvent):void {
			if (_is_menu_extended_bl) {
				var _evt:menuEvent = new menuEvent(menuEvent.HIDE_MENU);
			} else {
				var _evt:menuEvent = new menuEvent(menuEvent.SHOW_MENU);
			}
			extended = !_is_menu_extended_bl;
			dispatchEvent(_evt);
		}
	}
}